#!/usr/bin/env python
#coding: utf-8
'''
Created on 2017年2月22日

@author: Administrator
'''
from attachment.models import Attachment
from common.utils import storage
from django.contrib import admin

class AttachmentAdmin(admin.ModelAdmin):
    list_display = ('id','user','name','fpath','type','suffix','width','height','create_time','modify_time','admin_get_url')
    list_filter = ('state',)
    list_per_page = 50
    raw_id_fields = ('user',)
    search_fields = ('user__username','fpath','name','suffix',)

    def admin_get_url(self, obj):
        return u'<a href="%s" target="_blank">查看</a>' % (storage.get_absolute_url(obj.fpath))
    admin_get_url.short_description = u'预览'
    admin_get_url.allow_tags = True
admin.site.register(Attachment, AttachmentAdmin)